package sk.datalan.similarity.predicates;

import java.util.List;

public class Terrace implements Predicate {
	private String value = null;
	private boolean match = false;

	public Terrace( String value ) {
		this.value = value;
	}

	@Override
	public String getId() {
		return "http://www.datalan.sk/semweb/ontology/realestate/1.0/realestate.owl#hasTerrace";
	}

	@Override
	public String getValue() {
		return this.value;
	}

	@Override
	public double getWeight() {
		return 3;
	}

	@Override
	public double getSimilarityIndex( List<Predicate> predicates ) {
		double simTemp = 0;
		double similarity = Double.MAX_VALUE;

		for ( Predicate p : predicates ) {
			if ( getValue().equals( p.getValue() ) ) {
				simTemp = 1 * getWeight();
			} else {
				simTemp = 1.4 * getWeight();
			}

			if ( simTemp < similarity ) {
				similarity = simTemp;
				setMatch( true );
			}
		}

		return similarity;
	}

	@Override
	public boolean hasMatch() {
		return this.match;
	}

	@Override
	public void reset() {
		setMatch( false );
	}

	@Override
	public void setMatch( boolean value ) {
		this.match = value;
	}

}
